package com.hrabbit.admin.modual.system.controller;

import com.hrabbit.admin.modual.system.bean.SysUser;
import com.hrabbit.admin.modual.system.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 系统用户
 *
 * @Auther: hrabbit
 * @Date: 2018-12-17 6:21 PM
 * @Description:
 */
@Controller
@RequestMapping("user")
@Api(value = "系统用户")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 根据id获取用户信息
     *
     * @return
     */
    @RequestMapping(value = "/",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "进入到主页")
    public Object index() {
        return sysUserService.selectById(1L);
    }

    /**
     * 创建用户信息
     *
     * @param user
     * @return
     */
    @ApiOperation(value = "创建用户", notes = "根据SysUser对象创建用户")
    @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "SysUser")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public String postUser(@RequestBody SysUser user) {
        return "success";
    }

    /**
     * 修改用户信息
     *
     * @param id
     * @param user
     * @return
     */
    @ApiOperation(value = "更新用户详细信息", notes = "根据id更新系统用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "user", value = "用户详细实体sysUser", required = true, dataType = "SysUser")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public String putUser(@PathVariable Long id, @RequestBody SysUser user) {
        return "success";
    }

}
